package com.ylbh.modules.shoppingegg.controller;

import com.ylbh.common.annotation.SysLog;
import com.ylbh.common.pojo.brand.dto.BrandGoodsDTO;
import com.ylbh.common.pojo.brand.dto.ShoppingGoodsBrandDTO;
import com.ylbh.common.pojo.egg.dto.ShoppingEggDTO;
import com.ylbh.common.pojo.egg.vo.UpgradeSettingVO;
import com.ylbh.common.utils.CommonResult;
import com.ylbh.common.utils.PageUtils;
import com.ylbh.common.utils.Ref;
import com.ylbh.modules.shoppingegg.entity.ShoppingEgg;
import com.ylbh.modules.shoppingegg.service.ShoppingEggService;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 彩蛋管理列表
 * @author wjc
 * @date 2020-01-08
 */
@RestController
@RequestMapping("egg")
public class ShoppingEggController {

    @Autowired
    private ShoppingEggService shoppingEggService;

    @ApiOperation("彩蛋管理列表")
    @RequestMapping("queryGoodsEggList")
    public CommonResult<PageUtils> queryGoodsEggList(ShoppingEggDTO shoppingEggDTO){
        PageUtils eggList =shoppingEggService.queryGoodsEggList(shoppingEggDTO);
        return Ref.ok(eggList);
    }

    @ApiOperation("获取彩蛋升级信息")
    @RequestMapping("getUpgradeInfo")
    public CommonResult getUpgradeInfo(){
        List<UpgradeSettingVO> list = shoppingEggService.getUpgradeInfo();
        return Ref.ok(list);
    }

    @SysLog("蛋升添加")
    @ApiOperation("蛋升添加")
    @PostMapping("addUpgradeInfo")
    public CommonResult addUpgradeInfo(@RequestBody ShoppingEggDTO shoppingEggDTO){
        shoppingEggService.addUpgradeInfo(shoppingEggDTO);
        return Ref.ok();
    }
    @ApiOperation("根据ID查询蛋升信息")
    @GetMapping("getUpgradeById/{id}")
    public CommonResult getUpgradeById(@PathVariable String id) {
        ShoppingEgg shoppingEgg  =shoppingEggService.getUpgradeById(id);
        return Ref.ok(shoppingEgg);
    }

    @ApiOperation("根据ID修改彩蛋信息")
    @PostMapping("modifyUpgradeInfo")
    public CommonResult modifyUpgradeInfo(@RequestBody ShoppingEggDTO shoppingEggDTO){
        shoppingEggService.modifyUpgradeInfo(shoppingEggDTO);
        return  Ref.ok();
    }

    @ApiOperation("删除彩蛋信息")
    @PostMapping("removeEggByIds")
    public CommonResult removeEggByIds(@RequestBody String[] ids) {
        shoppingEggService.removeEggByIds(ids[0]);
        return  Ref.ok();
    }

    @SysLog("批量修改彩蛋信息状态")
    @ApiOperation("批量修改彩蛋信息状态")
    @RequestMapping("modifyEggStateByIds/{batchValue}")
    public CommonResult<Void> modifyEggStateByIds(@PathVariable String batchValue, @RequestBody String[] ids){
        shoppingEggService.modifyEggStateByIds(batchValue,ids);
        return Ref.ok();
    }

    @SysLog("修改彩蛋信息状态")
    @ApiOperation("修改彩蛋信息状态")
    @RequestMapping("modifyEggStateById")
    public CommonResult<Void> modifyEggStateById(@RequestBody  ShoppingEggDTO shoppingEggDTO){
        shoppingEggService.modifyEggStateById(shoppingEggDTO);
        return Ref.ok();
    }

    @SysLog("修改品牌显示状态")
    @ApiOperation("修改品牌显示状态")
    @RequestMapping("modifyBrandShowStateById")
    public CommonResult<Void> modifyBrandShowStateById(@RequestBody  BrandGoodsDTO brandGoodsDTO){
       // shoppingBrandGoodsService.modifyBrandShowStateById(brandGoodsDTO);
        return Ref.ok();
    }

}
